package utils;

import beans.BlockBean;
import block.Blockchain;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

/**
 * @author:zhengyilong
 * @email:1797344574@qq.com
 * @phone:13479394730
 * @desc:
 * @DateTime:2022/5/14 22:52
 **/
public class PrintAllBlock {
    public static void printAllBlock(){
        ArrayList<BlockBean> blocks = Blockchain.GetAllBlock();
        for (BlockBean block : blocks) {
            byte[] data = block.getData();
            long timestamp = block.getTimestamp();
            byte[] prevBlockHash = block.getPrevBlockHash();
            byte[] hash = block.getHash();
            long nonce = block.getNonce();

            System.out.println("data："+new String(data, StandardCharsets.UTF_8));
            System.out.println("timestamp："+timestamp);
            System.out.println("prevBlockHash："+ByteArrToHexString.getByteArrToHexString(prevBlockHash));
            System.out.println("hash："+ByteArrToHexString.getByteArrToHexString(hash));
            System.out.println("nonce："+nonce);
            System.out.println();
        }
    }
}

